package com.ys.controller.web.business;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ys.config.MenuId;
import com.ys.entity.business.TpAmazonShopExchangeRate;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.W;

@Controller
@RequestMapping("/web/business/tpAmazonShopExchangeRate")
public class WebTpAmazonShopExchangeRateController {
	

	@Autowired
	private CommonApiService<TpAmazonShopExchangeRate> commonApiService;
	
	/*
	 * 新增
	 */
	@GetMapping("/toAdd")
	public String toAdd(Model model){
		try {

			return commonApiService.toAdd(model,new TpAmazonShopExchangeRate().setStatus(1), MenuId.TP_AmazonShopExchangeRate, null, null);

		} catch (Exception e) {
			e.printStackTrace();
			return W.error(model, e.getMessage());
		}
	}



	/*
	 * 编辑
	 */
	@GetMapping("/toEdit")
	public String toEdit(Model model, Long id){
		if (id == null){
			return W.error(model, "id不能为空");
		}

		if (new TpAmazonShopExchangeRate().setId(id).count() == 0){
			return W.error(model, "该币种信息不存在!");
		}

		try {
			return commonApiService.toEdit(model, id, new TpAmazonShopExchangeRate(), MenuId.TP_AmazonShopExchangeRate, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			return W.error(model, "数据出错，请联系客服");
		}
	}

}
